<?php
/**
 * Created by PhpStorm.
 * User: 17208
 * Date: 2019/6/20
 * Time: 10:05
 */

namespace app\api\controller;

use app\common\lib\Request;
use think\Exception;
use app\common\lib\Export;
use app\common\lib\Redis;

class Matching extends Base
{
    private $cmd_data = [
        "100"=>"matching",   //在线匹配
    ];
    public function index(){
        try{
            // 检验登录情况
            parent::check_user_info();

            $cmd = Request::get('cmd');
            if(!isset($this->cmd_data[$cmd])) throw new Exception("参数错误");
            $method = $this->cmd_data[$cmd];

            $this->$method();
        }catch (Exception $e){
            Export::exp_err($e->getMessage());
        }

        return '';
    }
    private function matching(){
        $matching_people = Redis::get(config("REDIS_MATCHING"));
        $matching_people[] = $this->user_id;
        Redis::set(config("REDIS_MATCHING"),$matching_people);
        Export::exp_ok();
    }
}